#include "log.h"
#include "stm32L4xx_hal.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>

extern UART_HandleTypeDef hlpuart1;


int fputc(int ch, FILE *f)
{
    uint8_t temp[1] = {ch};
    HAL_UART_Transmit(&hlpuart1, temp, 1, 2);

    return 1;
}


void st_log(const char *format, ...)
{
    va_list ap;
    char str[128];

    memset(str, 0, sizeof(str));
    
    va_start(ap, format);
    (void)vsnprintf(str, sizeof(str), format, ap);
    va_end(ap);

    strcat(str, "\r\n");

    HAL_UART_Transmit(&hlpuart1, (uint8_t *)str, strlen(str), 20);
}



